<?php

namespace Cumulon\Service\History;

use Curl\Curl;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class HttpHistoryPodcast implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, SerializesModels;

    /**
     * 任务发送到的队列的名称.
     *
     * @var string|null
     */
    public $queue = '{http_url}';


    /**
     * 任务可以执行的最大秒数 (超时时间)。
     *
     * @var int
     */
    public $timeout = 1000;


    protected $postData;
    protected $url;
    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($postData,$url)
    {
        $this->postData = $postData;
        $this->url = $url;
    }

    /**
     * base64解密时
     * $str = str_replace("%3D","=",$str);
     * $str = str_replace("%2F","/",$str);
     * $str = str_replace(" ","+",$str);
     */

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $curl = new Curl();
        $curl->post( $this->url , [
            'postData' => base64_encode($this->postData),
        ]);
    }
}
